home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume8 / jove / part08 < prev    next >
Encoding:
Internet Message Format  |  1987-02-03  |  60.1 KB

  1. Subject:  v08i027:  The JOVE text editor, Part08/13
  2. Newsgroups: mod.sources
  3. Approved: mirror!rs
  4.  
  5. Submitted by: seismo!rochester!jpayne (Jonathan Payne)
  6. Mod.sources: Volume 8, Issue 27
  7. Archive-name: jove/Part08
  8.  
  9. #! /bin/sh
  10. # This is a shell archive.  Remove anything before this line,
  11. # then unpack it by saving it in a file and typing "sh file".
  12. # If all goes well, you will see the message "End of archive 8 (of 13)."
  13. # Contents:  temp.h term.c termcap.h tune.h util.c vars.c wind.c
  14. #   doc/README doc/example.rc doc/jove.3 doc/system.rc
  15. #   doc/teachjove.nr
  16. PATH=/bin:/usr/bin:/usr/ucb; export PATH
  17. echo shar: extracting "'temp.h'" '(3368 characters)'
  18. if test -f 'temp.h' ; then 
  19.   echo shar: will not over-write existing file "'temp.h'"
  20. else
  21. sed 's/^X//' >temp.h <<'@//E*O*F temp.h//'
  22. X/************************************************************************
  23. X * This program is Copyright (C) 1986 by Jonathan Payne.  JOVE is       *
  24. X * provided to you without charge, and with no warranty.  You may give  *
  25. X * away copies of JOVE, including sources, provided that this notice is *
  26. X * included in all the files.                                           *
  27. X ************************************************************************/
  28. X
  29. X/* The tmp file is indexed in chunks of CH_SIZE characters.  CH_SIZE is
  30. X   (1 << CH_BITS).  New lines are added to the end of the tmp file.  The
  31. X   file is not garbage collected because that would be too painful.  As a
  32. X   result, commands like Yank and Kill are really easy; basically all we
  33. X   do is make copies of the disk addresses of the lines (as opposed to
  34. X   the contents).  So, putline(buf) writes BUF to the disk and returns a
  35. X   new disk address.  Getline(addr, buf) is the opposite of putline().
  36. X   f_getputl(line, fp) reads from open FP directly into the tmp file (into
  37. X   the buffer cache (see below)) and stores the address in LINE.  This is
  38. X   used during read_file to minimize compying.
  39. X
  40. X   Lines do NOT cross block bounderies in the tmp file so that accessing
  41. X   the contents of lines can be much faster.  Pointers to offsets into
  42. X   disk buffers are returned instead of copying the contents into local
  43. X   arrays and then using them.  This cuts down on the amount of copying a
  44. X   great deal, at the expense of less efficiency.  The lower bit of disk
  45. X   addresses is used for marking lines as needing redisplay done.
  46. X
  47. X   There is a buffer cache of NBUF buffers (64 on !SMALL machines and the
  48. X   3 on small ones).  The blocks are stored in LRU order and each block
  49. X   is also stored in a hash table by block #.  When a block is requested
  50. X   it can quickly be looked up in the hash table.  If it's not there the
  51. X   LRU block is assigned the new block #.  If it finds that the LRU block
  52. X   is dirty (i.e., has pending IO) it syncs the WHOLE tmp file, i.e.,
  53. X   does all the pending writes.  This works much better on floppy disk
  54. X   systems, like the IBM PC, if the blocks are sorted before sync'ing. */
  55. X
  56. X#ifdef SMALL
  57. X#   define CH_BITS        4
  58. X#   if BUFSIZ == 512
  59. X#    define MAX_BLOCKS    1024
  60. X#   else
  61. X#    define MAX_BLOCKS    512
  62. X#   endif
  63. X#else
  64. X#   define CH_BITS        0
  65. X#   define MAX_BLOCKS        4096    /* basically unlimited */
  66. X#endif SMALL
  67. X
  68. X#if BUFSIZ == 512
  69. X#   define BNO_SHIFT        (9 - CH_BITS)
  70. X#else
  71. X#   define BNO_SHIFT        (10 - CH_BITS)
  72. X#endif
  73. X
  74. X/* CH_SIZE is how big each chunk is.  For each 1 the DFree pointer
  75. X   is incremented we extend the tmp file by CH_SIZE characters.
  76. X   CH_PBLOCK is the # of chunks per block.  RND_MASK is used to mask
  77. X   off the lower order bits of the daddr to round down to the beginning
  78. X   of a block.  OFF_MASK masks off the higher order bits so we can get
  79. X   at the offset into the disk buffer.
  80. X
  81. X   NOTE:  It's pretty important that these numbers be multiples of
  82. X      2.  Be careful if you change things. */
  83. X
  84. X#define CH_SIZE            (1 << CH_BITS)
  85. X#define CH_PBLOCK        (BUFSIZ / CH_SIZE)
  86. X#define RND_MASK        (CH_PBLOCK - 1)
  87. X#define OFF_MASK        (BUFSIZ - 1)
  88. X#define BNO_MASK        (MAX_BLOCKS - 1)
  89. X#define blk_round(daddr)    (daddr & ~RND_MASK)
  90. X#define forward_block(daddr)    (daddr + CH_PBLOCK)
  91. X#define daddr_to_bno(daddr)    ((daddr >> BNO_SHIFT) & BNO_MASK)
  92. X#define daddr_to_off(daddr)    ((daddr << CH_BITS) & OFF_MASK)
  93. @//E*O*F temp.h//
  94. if test 3368 -ne "`wc -c <'temp.h'`"; then
  95.     echo shar: error transmitting "'temp.h'" '(should have been 3368 characters)'
  96. fi
  97. fi # end of overwriting check
  98. echo shar: extracting "'term.c'" '(3672 characters)'
  99. if test -f 'term.c' ; then 
  100.   echo shar: will not over-write existing file "'term.c'"
  101. else
  102. sed 's/^X//' >term.c <<'@//E*O*F term.c//'
  103. X/************************************************************************
  104. X * This program is Copyright (C) 1986 by Jonathan Payne.  JOVE is       *
  105. X * provided to you without charge, and with no warranty.  You may give  *
  106. X * away copies of JOVE, including sources, provided that this notice is *
  107. X * included in all the files.                                           *
  108. X ************************************************************************/
  109. X
  110. X#include "jove.h"
  111. X#include <errno.h>
  112. X#ifdef SYSV
  113. X#   include <termio.h>
  114. X#else
  115. X#   include <sgtty.h>
  116. X#endif SYSV
  117. X
  118. X#ifdef IPROCS
  119. X#   include <signal.h>
  120. X#endif
  121. X
  122. X/* Termcap definitions */
  123. X
  124. Xchar    *UP,
  125. X    *CS,
  126. X    *SO,
  127. X    *SE,
  128. X    *CM,
  129. X    *CL,
  130. X    *CE,
  131. X    *HO,
  132. X    *AL,
  133. X    *DL,
  134. X    *VS,
  135. X    *VE,
  136. X    *KS,
  137. X    *KE,
  138. X    *TI,
  139. X    *TE,
  140. X    *IC,
  141. X    *DC,
  142. X    *IM,
  143. X    *EI,
  144. X    *LL,
  145. X    *BC,
  146. X    *M_IC,    /* Insert char with arg */
  147. X    *M_DC,    /* Delete char with arg */
  148. X    *M_AL,    /* Insert line with arg */
  149. X    *M_DL,    /* Delete line with arg */
  150. X    *SF,    /* Scroll forward */
  151. X    *SR,
  152. X    *SP,    /* Send Cursor Position */
  153. X#ifdef LSRHS
  154. X    *RS,    /* Reverse video start */
  155. X    *RE,    /* Reverse end */
  156. X#endif
  157. X    *VB,
  158. X    *IP,    /* insert pad after character inserted */
  159. X    *lPC;
  160. X
  161. Xint    LI,
  162. X    ILI,    /* Internal lines, i.e., 23 of LI is 24. */
  163. X    CO,
  164. X
  165. X    UL,
  166. X    MI,
  167. X    SG,    /* number of magic cookies left by SO and SE */
  168. X    XS,    /* whether standout is braindamaged */
  169. X
  170. X    TABS,
  171. X    UPlen,
  172. X    HOlen,
  173. X    LLlen;
  174. X
  175. X#ifdef SYSV /* release 2, at least */
  176. Xchar PC ;
  177. X#else
  178. Xextern char    PC;
  179. X#endif SYSV
  180. X
  181. Xstatic char    tspace[256];
  182. X
  183. X/* The ordering of ts and meas must agree !! */
  184. X#ifdef LSRHS
  185. Xstatic char    *ts="vsvealdlspcssosecmclcehoupbcicimdceillsfsrvbksketiteALDLICDCrsrepcip";
  186. Xstatic char    **meas[] = {
  187. X    &VS, &VE, &AL, &DL, &SP, &CS, &SO, &SE,
  188. X    &CM, &CL, &CE, &HO, &UP, &BC, &IC, &IM,
  189. X    &DC, &EI, &LL, &SF, &SR, &VB, &KS, &KE,
  190. X    &TI, &TE, &M_AL, &M_DL, &M_IC, &M_DC,
  191. X    &RS, &RE, &lPC, &IP, 0
  192. X};
  193. X#else
  194. Xstatic char    *ts="vsvealdlspcssosecmclcehoupbcicimdceillsfsrvbksketiteALDLICDCpcip";
  195. Xstatic char    **meas[] = {
  196. X    &VS, &VE, &AL, &DL, &SP, &CS, &SO, &SE,
  197. X    &CM, &CL, &CE, &HO, &UP, &BC, &IC, &IM,
  198. X    &DC, &EI, &LL, &SF, &SR, &VB, &KS, &KE,
  199. X    &TI, &TE, &M_AL, &M_DL, &M_IC, &M_DC,
  200. X    &lPC, &IP, 0
  201. X};
  202. X#endif
  203. X
  204. Xstatic
  205. Xgets(buf)
  206. Xchar    *buf;
  207. X{
  208. X    buf[read(0, buf, 12) - 1] = 0;
  209. X}    
  210. X
  211. X/* VARARGS1 */
  212. X
  213. Xstatic
  214. XTermError(fmt, a)
  215. Xchar    *fmt;
  216. X{
  217. X    printf(fmt, a);
  218. X    _exit(1);
  219. X}
  220. X
  221. XgetTERM()
  222. X{
  223. X    char    *getenv(), *tgetstr() ;
  224. X    char    termbuf[13],
  225. X        *termname = 0,
  226. X        *termp = tspace,
  227. X        tbuff[2048];    /* Good grief! */
  228. X    int    i;
  229. X
  230. X    termname = getenv("TERM");
  231. X    if (termname == 0) {
  232. X        putstr("Enter terminal name: ");
  233. X        gets(termbuf);
  234. X        if (termbuf[0] == 0)
  235. X            TermError(NullStr);
  236. X
  237. X        termname = termbuf;
  238. X    }
  239. X
  240. X    if (tgetent(tbuff, termname) < 1)
  241. X        TermError("[\"%s\" unknown terminal type?]", termname);
  242. X
  243. X    if ((CO = tgetnum("co")) == -1)
  244. X        TermError("columns?");
  245. X
  246. X    if ((LI = tgetnum("li")) == -1)
  247. X        TermError("lines?");
  248. X
  249. X    if ((SG = tgetnum("sg")) == -1)
  250. X        SG = 0;            /* Used for mode line only */
  251. X
  252. X    if ((XS = tgetflag("xs")) == -1)
  253. X        XS = 0;            /* Used for mode line only */
  254. X
  255. X    for (i = 0; meas[i]; i++) {
  256. X        *(meas[i]) = (char *) tgetstr(ts, &termp);
  257. X        ts += 2;
  258. X    }
  259. X    if (lPC)
  260. X        PC = *lPC;
  261. X    if (XS)
  262. X        SO = SE = 0;
  263. X
  264. X    if (CS && !SR)
  265. X        CS = SR = SF = 0;
  266. X
  267. X    if (CS && !SF)
  268. X        SF = "\n";
  269. X
  270. X    if (IM && (*IM == 0))
  271. X        IM = 0;
  272. X    else
  273. X        MI = tgetflag("mi");
  274. X
  275. X    UL = tgetflag("ul");
  276. X
  277. X#ifdef LSRHS        /* We, at the high school, are the only ones who
  278. X               do SO right in termcap, but unfortunately the
  279. X               right SO doesn't look as good with modelines. */
  280. X    if (RS)
  281. X        SO = RS;
  282. X    if (RE)
  283. X        SE = RE;
  284. X            /* I only ever use SO for the modeline anyway. */
  285. X
  286. X/* SO is really BOLDFACE!  Why is LS always right and the rest of the
  287. X   world wrong? */
  288. X#endif
  289. X#ifdef ID_CHAR
  290. X    disp_opt_init();
  291. X#endif
  292. X    if (CanScroll = ((AL && DL) || CS))
  293. X        IDline_setup(termname);
  294. X}
  295. X
  296. @//E*O*F term.c//
  297. if test 3672 -ne "`wc -c <'term.c'`"; then
  298.     echo shar: error transmitting "'term.c'" '(should have been 3672 characters)'
  299. fi
  300. fi # end of overwriting check
  301. echo shar: extracting "'termcap.h'" '(1965 characters)'
  302. if test -f 'termcap.h' ; then 
  303.   echo shar: will not over-write existing file "'termcap.h'"
  304. else
  305. sed 's/^X//' >termcap.h <<'@//E*O*F termcap.h//'
  306. X/************************************************************************
  307. X * This program is Copyright (C) 1986 by Jonathan Payne.  JOVE is       *
  308. X * provided to you without charge, and with no warranty.  You may give  *
  309. X * away copies of JOVE, including sources, provided that this notice is *
  310. X * included in all the files.                                           *
  311. X ************************************************************************/
  312. X
  313. X/* Termcap definitions */
  314. X
  315. Xextern char
  316. X    *UP,    /* Scroll reverse, or up */
  317. X    *CS,    /* If on vt100 */
  318. X    *SO,    /* Start standout */
  319. X    *SE,    /* End standout */
  320. X    *CM,    /* The cursor motion string */
  321. X    *CL,    /* Clear screen */
  322. X    *CE,    /* Clear to end of line */
  323. X    *HO,    /* Home cursor */
  324. X    *AL,    /* Addline (insert line) */
  325. X    *DL,    /* Delete line */
  326. X    *VS,    /* Visual start */
  327. X    *VE,    /* Visual end */
  328. X    *KS,    /* Keypad mode start */
  329. X    *KE,    /* Keypad mode end */
  330. X    *TI,    /* Cursor addressing start */
  331. X    *TE,    /* Cursor addressing end */
  332. X    *IC,    /* Insert char */
  333. X    *DC,    /* Delete char */
  334. X    *IM,    /* Insert mode */
  335. X    *EI,    /* End insert mode */
  336. X    *LL,    /* Last line, first column */
  337. X    *M_IC,    /* Insert char with arg */
  338. X    *M_DC,    /* Delete char with arg */
  339. X    *M_AL,    /* Insert line with arg */
  340. X    *M_DL,    /* Delete line with arg */
  341. X    *SF,    /* Scroll forward */
  342. X    *SR,    /* Scroll reverse */
  343. X    *SP,    /* Send cursor position */
  344. X#ifdef LSRHS
  345. X    *RS,    /* reverse video start */
  346. X    *RE,    /* reverse video end */
  347. X#endif
  348. X    *VB,    /* visible bell */
  349. X    *IP,    /* insert pad after character inserted */
  350. X    *lPC;
  351. X
  352. Xextern int
  353. X    LI,        /* number of lines */
  354. X    ILI,        /* number of internal lines */
  355. X    CO,        /* number of columns */
  356. X
  357. X    UL,        /* underscores don't replace chars already on screen */
  358. X    MI,        /* okay to move while in insert mode */
  359. X    SG,        /* number of magic cookies left by SO and SE */
  360. X
  361. X    TABS,        /* whether we are in tabs mode */
  362. X    UPlen,        /* length of the UP string */
  363. X    HOlen,        /* length of Home string */
  364. X    LLlen;        /* length of lower string */
  365. X
  366. Xextern char
  367. X    PC,
  368. X    *BC;        /* back space */
  369. X
  370. Xextern short    ospeed;
  371. @//E*O*F termcap.h//
  372. if test 1965 -ne "`wc -c <'termcap.h'`"; then
  373.     echo shar: error transmitting "'termcap.h'" '(should have been 1965 characters)'
  374. fi
  375. fi # end of overwriting check
  376. echo shar: extracting "'tune.h'" '(3598 characters)'
  377. if test -f 'tune.h' ; then 
  378.   echo shar: will not over-write existing file "'tune.h'"
  379. else
  380. sed 's/^X//' >tune.h <<'@//E*O*F tune.h//'
  381. X/************************************************************************
  382. X * This program is Copyright (C) 1986 by Jonathan Payne.  JOVE is       *
  383. X * provided to you without charge, and with no warranty.  You may give  *
  384. X * away copies of JOVE, including sources, provided that this notice is *
  385. X * included in all the files.                                           *
  386. X ************************************************************************/
  387. X
  388. X#define TUNED        /* don't touch this */
  389. X
  390. X/*#define LSRHS        /* if this is Lincoln-Sudbury Regional High School */
  391. X/*#define MSDOS        /* if this is MSDOS */
  392. X#define BSD4_2        /* Berkeley 4.2 BSD */
  393. X/*#define BSD4_3    /* Berkeley 4.3 BSD */
  394. X/*#define SYSV        /* for (System III/System V) UNIX systems */
  395. X#ifdef BSD4_3
  396. X#   ifndef BSD4_2
  397. X#    define BSD4_2    /* 4.3 is 4.2 only different. */
  398. X#   endif
  399. X#endif
  400. X
  401. X
  402. X#ifdef MSDOS
  403. X#   define SMALL
  404. X#else            /* assume we're UNIX or something */
  405. X#   if vax || sel || sun || pyr || mc68000 || tahoe || iAPX286
  406. X#    define VMUNIX        /* Virtual Memory UNIX */
  407. X#    define BUFSIZ    1024
  408. X#    if iAPX286
  409. X#        define NBUF    48
  410. X#    else
  411. X#        define NBUF    64    /* number of disk buffers */
  412. X#    endif iAPX286
  413. X#   else
  414. X#    define SMALL
  415. X#    define BUFSIZ    512    /* or 1024 */
  416. X#    define NBUF    3
  417. X#   endif
  418. X#
  419. X/* #   define LOAD_AV    /* Use the load average for various commands.
  420. X#               Do not define this if you lack a load average
  421. X#               system call and kmem is read protected. */
  422. X#
  423. X#   define JOB_CONTROL    /* if you have job stopping */
  424. X#
  425. X#   ifdef JOB_CONTROL
  426. X#       define MENLO_JCL
  427. X#       define IPROCS    /* Interactive processes only work with JOB_CONTROL. */
  428. X#   endif
  429. X#
  430. X#   define SUBPROCS    /* only on UNIX systems (NOT INCORPORATED YET) */
  431. X#endif MSDOS
  432. X
  433. X#ifdef SMALL
  434. X    typedef    short    disk_line;
  435. X#else
  436. X#   if iAPX286
  437. X    typedef long    disk_line;
  438. X#   else
  439. X    typedef    int    disk_line;
  440. X#   endif iAPX286
  441. X#endif SMALL
  442. X
  443. X#ifndef SMALL
  444. X#   define ABBREV        /* word abbreviation mode */
  445. X#   define BACKUPFILES        /* enable the backup files code */
  446. X#   ifndef MSDOS
  447. X#       define BIFF        /* if you have biff (or the equivalent) */
  448. X#       define F_COMPLETION    /* filename completion */
  449. X#       define CHDIR        /* cd command and absolute pathnames */
  450. X#       define    KILL0    /* kill(pid, 0) returns 0 if proc exists */
  451. X#       define SPELL        /* spell words and buffer commands */
  452. X#       define ID_CHAR        /* include code to IDchar */
  453. X#       define WIRED_TERMS    /* include code for wired terminals */
  454. X#       define ANSICODES    /* extra commands that process ANSI codes */
  455. X#   endif
  456. X#   define LISP            /* include the code for Lisp Mode */
  457. X#   define CMT_FMT        /* include the comment formatting routines */
  458. X#endif SMALL
  459. X
  460. X#if !sun && !iAPX286
  461. X#   define MY_MALLOC    /* use more memory efficient malloc (not on suns) */
  462. X#endif
  463. X
  464. X#define DFLT_MODE    0666    /* file will be created with this mode */
  465. X
  466. X#ifdef BSD4_3
  467. X#   define RESHAPING    /* enable windows to handle reshaping */
  468. X#endif
  469. X
  470. X#ifdef BSD4_2            /* byte_copy(from, to, len) */
  471. X#   define    byte_copy bcopy    /* use fast assembler version */
  472. X#endif
  473. X
  474. X#ifdef IPROCS
  475. X#   ifdef BSD4_2
  476. X#    define INPUT_SIG    SIGIO
  477. X#   else
  478. X#    define PIPEPROCS        /* do it with pipes */
  479. X#    define INPUT_SIG    SIGTINT
  480. X#   endif
  481. X#endif
  482. X
  483. X#ifdef SYSV
  484. X#   define byte_copy(s2, s1, n)    memcpy(s1, s2, n)
  485. X#   define bzero(s, n)    memset(s, 0, n)
  486. X#   define index    strchr
  487. X#   define rindex    strrchr
  488. X#endif
  489. X
  490. X/* These are here since they define things in tune.c.  If you add things to
  491. X   tune.c, add them here too, if necessary. */
  492. X
  493. X#ifndef NOEXTERNS
  494. Xextern char
  495. X    TmpFilePath[128],
  496. X    *d_tempfile,
  497. X    *p_tempfile,
  498. X    *Recover,
  499. X    *CmdDb,
  500. X    *Joverc,
  501. X
  502. X#ifdef PIPEPROCS
  503. X    *Portsrv,
  504. X#endif
  505. X
  506. X    Shell[],
  507. X    ShFlags[];
  508. X#endif NOEXTERNS
  509. @//E*O*F tune.h//
  510. if test 3598 -ne "`wc -c <'tune.h'`"; then
  511.     echo shar: error transmitting "'tune.h'" '(should have been 3598 characters)'
  512. fi
  513. fi # end of overwriting check
  514. echo shar: extracting "'util.c'" '(13431 characters)'
  515. if test -f 'util.c' ; then 
  516.   echo shar: will not over-write existing file "'util.c'"
  517. else
  518. sed 's/^X//' >util.c <<'@//E*O*F util.c//'
  519. X/************************************************************************
  520. X * This program is Copyright (C) 1986 by Jonathan Payne.  JOVE is       *
  521. X * provided to you without charge, and with no warranty.  You may give  *
  522. X * away copies of JOVE, including sources, provided that this notice is *
  523. X * included in all the files.                                           *
  524. X ************************************************************************/
  525. X
  526. X#include "jove.h"
  527. X#include "ctype.h"
  528. X#include <signal.h>
  529. X#include <varargs.h>
  530. X
  531. X#ifdef SYSV /* release 2, at least */
  532. Xshort ospeed ;
  533. X#endif
  534. X
  535. Xstruct cmd *
  536. XFindCmd(proc)
  537. Xregister int     (*proc)();
  538. X{
  539. X    register struct cmd    *cp;
  540. X
  541. X      for (cp = commands; cp->Name; cp++)
  542. X        if (cp->c_proc == proc)
  543. X            return cp;
  544. X    return 0;
  545. X}
  546. X
  547. Xint    Interactive;    /* True when we invoke with the command handler? */
  548. Xchar    *ProcFmt = ": %f ";
  549. X
  550. XExecCmd(cp)
  551. Xdata_obj    *cp;
  552. X{
  553. X    LastCmd = cp;
  554. X    if (cp->Type & MAJOR_MODE)
  555. X        SetMajor((cp->Type >> 8));
  556. X    else if (cp->Type & MINOR_MODE)
  557. X        TogMinor((cp->Type >> 8));
  558. X    else    switch (cp->Type&TYPEMASK) {
  559. X        case MACRO:
  560. X            do_macro((struct macro *) cp);
  561. X            break;
  562. X
  563. X        case FUNCTION:
  564. X            {
  565. X                struct cmd    *cmd = (struct cmd *) cp;
  566. X
  567. X            if (cmd->c_proc)
  568. X                (*cmd->c_proc)();
  569. X            }
  570. X    }
  571. X}
  572. X
  573. XLine *
  574. Xlastline(lp)
  575. Xregister Line    *lp;
  576. X{
  577. X    while (lp->l_next)
  578. X        lp = lp->l_next;
  579. X    return lp;
  580. X}
  581. X
  582. XUpper(c)
  583. Xregister int    c;
  584. X{
  585. X    return (islower(c) ? toupper(c) : c);
  586. X}
  587. X
  588. Xint    alarmed = 0;
  589. X
  590. Xchar    key_strokes[100];
  591. Xstatic char    *key_p = key_strokes;
  592. X
  593. Xinit_strokes()
  594. X{
  595. X    key_strokes[0] = 0;
  596. X    key_p = key_strokes;
  597. X}
  598. X
  599. Xadd_stroke(c)
  600. X{
  601. X    if (key_p + 5 > &key_strokes[(sizeof key_strokes) - 1])
  602. X        key_p = key_strokes;
  603. X    sprintf(key_p, "%p ", c);
  604. X    key_p += strlen(key_p);
  605. X}
  606. X
  607. Xslowpoke()
  608. X{
  609. X    alarmed++;
  610. X    f_mess(key_strokes);
  611. X}
  612. X
  613. X#ifdef BSD4_2
  614. X#    define N_SEC    1    /* will be precisely 1 second on 4.2 */
  615. X#else
  616. X#    define N_SEC    2    /* but from 0 to 2 seconds otherwise */
  617. X#endif
  618. X
  619. Xwaitchar()
  620. X{
  621. X#ifdef EUNICE
  622. X    return getch();
  623. X#endif
  624. X    unsigned int    old_time;
  625. X    int    c;
  626. X    int    (*oldproc)();
  627. X
  628. X    alarmed = 0;
  629. X    oldproc = signal(SIGALRM, slowpoke);
  630. X
  631. X    if ((old_time = alarm((unsigned) N_SEC)) == 0)
  632. X        old_time = UpdFreq;
  633. X    c = getch();
  634. X    (void) alarm(old_time);
  635. X    (void) signal(SIGALRM, oldproc);
  636. X
  637. X    return c;
  638. X}
  639. X
  640. X/* dir > 0 means forward; else means backward. */
  641. X
  642. Xchar *
  643. XStrIndex(dir, buf, charpos, what)
  644. Xchar    *buf,
  645. X    what;
  646. X{
  647. X    char    *cp = &buf[charpos],
  648. X        c;
  649. X
  650. X    if (dir > 0) {
  651. X        while (c = *cp++)
  652. X            if (c == what)
  653. X                return (cp - 1);
  654. X    } else {
  655. X        while (cp >= buf && (c = *cp--))
  656. X            if (c == what)
  657. X                return (cp + 1);
  658. X    }
  659. X    return 0;
  660. X}
  661. X
  662. Xblnkp(buf)
  663. Xregister char    *buf;
  664. X{
  665. X    register char    c;
  666. X
  667. X    while ((c = *buf++) && (c == ' ' || c == '\t'))
  668. X        ;
  669. X    return c == 0;    /* It's zero if we got to the end of the Line */
  670. X}
  671. X
  672. XLine *
  673. Xnext_line(line, num)
  674. Xregister Line    *line;
  675. Xregister int    num;
  676. X{
  677. X    if (num < 0)
  678. X        return prev_line(line, -num);
  679. X    if (line)
  680. X        while (--num >= 0 && line->l_next != 0)
  681. X            line = line->l_next;
  682. X    return line;
  683. X}
  684. X
  685. XLine *
  686. Xprev_line(line, num)
  687. Xregister Line    *line;
  688. Xregister int    num;
  689. X{
  690. X    if (num < 0)
  691. X        return next_line(line, -num);
  692. X    if (line)
  693. X        while (--num >= 0 && line->l_prev != 0)
  694. X            line = line->l_prev;
  695. X    return line;
  696. X}
  697. X
  698. XDotTo(line, col)
  699. XLine    *line;
  700. X{
  701. X    Bufpos    bp;
  702. X
  703. X    bp.p_line = line;
  704. X    bp.p_char = col;
  705. X    SetDot(&bp);
  706. X}
  707. X
  708. X/* If bp->p_line is != current line, then save current line.  Then set dot
  709. X   to bp->p_line, and if they weren't equal get that line into linebuf.  */
  710. X
  711. XSetDot(bp)
  712. Xregister Bufpos    *bp;
  713. X{
  714. X    register int    notequal;
  715. X
  716. X    if (bp == 0)
  717. X        return;
  718. X
  719. X    notequal = bp->p_line != curline;
  720. X    if (notequal)
  721. X        lsave();
  722. X    if (bp->p_line)
  723. X        curline = bp->p_line;
  724. X    curchar = bp->p_char;
  725. X    if (notequal)
  726. X        getDOT();
  727. X}
  728. X
  729. XToLast()
  730. X{
  731. X    SetLine(curbuf->b_last);
  732. X    Eol();
  733. X}
  734. X
  735. Xint    MarkThresh = 22;    /* Average screen size ... */
  736. Xstatic int    line_diff;
  737. X
  738. XLineDist(nextp, endp)
  739. Xregister Line    *nextp,
  740. X        *endp;
  741. X{
  742. X    (void) inorder(nextp, 0, endp, 0);
  743. X    return line_diff;
  744. X}
  745. X
  746. Xinorder(nextp, char1, endp, char2)
  747. Xregister Line    *nextp,
  748. X        *endp;
  749. X{
  750. X    int    count = 0;
  751. X    register Line    *prevp = nextp;
  752. X
  753. X    line_diff = 0;
  754. X    if (nextp == endp)
  755. X        return char1 < char2;
  756. X
  757. X    while (nextp || prevp) {
  758. X        if (nextp == endp || prevp == endp)
  759. X            break;
  760. X        if (nextp)
  761. X            nextp = nextp->l_next;
  762. X        if (prevp)
  763. X            prevp = prevp->l_prev;
  764. X        count++;
  765. X    }
  766. X    if (nextp == 0 && prevp == 0)
  767. X        return -1;
  768. X    line_diff = count;
  769. X
  770. X    return nextp == endp;
  771. X}
  772. X
  773. XPushPntp(line)
  774. Xregister Line    *line;
  775. X{
  776. X    exp_p = NO;
  777. X    if (LineDist(curline, line) >= MarkThresh)
  778. X        SetMark();
  779. X}
  780. X
  781. XToFirst()
  782. X{
  783. X    SetLine(curbuf->b_first);
  784. X}
  785. X
  786. Xlength(line)
  787. XLine    *line;
  788. X{
  789. X    return strlen(lcontents(line));
  790. X};
  791. X
  792. Xto_word(dir)
  793. Xregister int    dir;
  794. X{
  795. X    register char    c;
  796. X
  797. X    if (dir > 0) {
  798. X        while ((c = linebuf[curchar]) != 0 && !isword(c))
  799. X            curchar++;
  800. X        if (eolp()) {
  801. X            if (curline->l_next == 0)
  802. X                return;
  803. X            SetLine(curline->l_next);
  804. X            to_word(dir);
  805. X            return;
  806. X        }
  807. X    } else {
  808. X        while (!bolp() && (c = linebuf[curchar - 1], !isword(c)))
  809. X            --curchar;
  810. X        if (bolp()) {
  811. X            if (curline->l_prev == 0)
  812. X                return;
  813. X            SetLine(curline->l_prev);
  814. X            Eol();
  815. X            to_word(dir);
  816. X        }
  817. X    }
  818. X}
  819. X
  820. X/* Are there any modified buffers?  Allp means include B_PROCESS
  821. X   buffers in the check. */
  822. X
  823. XModBufs(allp)
  824. X{
  825. X    register Buffer    *b;
  826. X
  827. X    for (b = world; b != 0; b = b->b_next) {
  828. X        if (b->b_type == B_SCRATCH)
  829. X            continue;
  830. X        if ((b->b_type == B_FILE || allp) && IsModified(b))
  831. X            return 1;
  832. X    }
  833. X    return 0;
  834. X}
  835. X
  836. Xchar *
  837. Xfilename(b)
  838. Xregister Buffer    *b;
  839. X{
  840. X    return b->b_fname ? pr_name(b->b_fname) : "[No file]";
  841. X}
  842. X
  843. Xchar *
  844. Xitoa(num)
  845. Xregister int    num;
  846. X{
  847. X    static char    line[15];
  848. X
  849. X    sprintf(line, "%d", num);
  850. X    return line;
  851. X}
  852. X
  853. Xmin(a, b)
  854. Xregister int    a,
  855. X        b;
  856. X{
  857. X    return (a < b) ? a : b;
  858. X}
  859. X
  860. Xmax(a, b)
  861. Xregister int    a,
  862. X        b;
  863. X{
  864. X    return (a > b) ? a : b;
  865. X}
  866. X
  867. Xtiewind(w, bp)
  868. Xregister Window    *w;
  869. Xregister Buffer    *bp;
  870. X{
  871. X    int    not_tied = (w->w_bufp != bp);
  872. X
  873. X    UpdModLine++;    /* Kludge ... but speeds things up considerably */
  874. X    w->w_line = bp->b_dot;
  875. X    w->w_char = bp->b_char;
  876. X    w->w_bufp = bp;
  877. X    if (not_tied)
  878. X        CalcWind(w);    /* ah, this has been missing since the
  879. X                   beginning of time! */
  880. X}
  881. X
  882. Xextern int    Jr_Len;
  883. X
  884. Xchar *
  885. Xlcontents(line)
  886. Xregister Line    *line;
  887. X{
  888. X    if (line == curline)
  889. X        return linebuf;
  890. X    else
  891. X        return lbptr(line);
  892. X}
  893. X
  894. Xchar *
  895. Xltobuf(line, buf)
  896. XLine    *line;
  897. Xchar    *buf;
  898. X{
  899. X    if (line == curline) {
  900. X        if (buf != linebuf)
  901. X            strcpy(buf, linebuf);
  902. X        Jr_Len = strlen(linebuf);
  903. X    } else
  904. X        getline(line->l_dline, buf);
  905. X    return buf;
  906. X}
  907. X
  908. XDOTsave(buf)
  909. XBufpos *buf;
  910. X{
  911. X    buf->p_line = curline;
  912. X    buf->p_char = curchar;
  913. X}
  914. X
  915. X/* Return none-zero if we had to rearrange the order. */
  916. X
  917. Xfixorder(line1, char1, line2, char2)
  918. Xregister Line    **line1,
  919. X        **line2;
  920. Xregister int    *char1,
  921. X        *char2;
  922. X{
  923. X    Line    *tline;
  924. X    int    tchar;
  925. X
  926. X    if (inorder(*line1, *char1, *line2, *char2))
  927. X        return 0;
  928. X
  929. X    tline = *line1;
  930. X    tchar = *char1;
  931. X    *line1 = *line2;
  932. X    *char1 = *char2;
  933. X    *line2 = tline;
  934. X    *char2 = tchar;
  935. X
  936. X    return 1;
  937. X}
  938. X
  939. Xinlist(first, what)
  940. Xregister Line    *first,
  941. X        *what;
  942. X{
  943. X    while (first) {
  944. X        if (first == what)
  945. X            return 1;
  946. X        first = first->l_next;
  947. X    }
  948. X    return 0;
  949. X}
  950. X
  951. X/* Make `buf' modified and tell the redisplay code to update the modeline
  952. X   if it will need to be changed. */
  953. X
  954. Xint    ModCount = 0;
  955. X
  956. Xmodify()
  957. X{
  958. X    extern int    DOLsave;
  959. X
  960. X    if (!curbuf->b_modified)
  961. X        UpdModLine++;
  962. X    curbuf->b_modified++;
  963. X    DOLsave++;
  964. X    if (!Asking)
  965. X        ModCount++;
  966. X}
  967. X
  968. Xunmodify()
  969. X{
  970. X    if (curbuf->b_modified)
  971. X        UpdModLine++;
  972. X    curbuf->b_modified = 0;
  973. X}
  974. X
  975. Xnumcomp(s1, s2)
  976. Xregister char    *s1,
  977. X        *s2;
  978. X{
  979. X    register int    count = 0;
  980. X
  981. X    while (*s1 != 0 && *s1++ == *s2++)
  982. X        count++;
  983. X    return count;
  984. X}
  985. X
  986. Xchar *
  987. Xcopystr(str)
  988. Xchar    *str;
  989. X{
  990. X    char    *val = emalloc(strlen(str) + 1);
  991. X
  992. X    strcpy(val, str);
  993. X    return val;
  994. X}
  995. X
  996. X#ifndef byte_copy
  997. Xbyte_copy(from, to, count)
  998. Xregister char    *from,
  999. X        *to;
  1000. Xregister int    count;
  1001. X{
  1002. X    while (--count >= 0)
  1003. X        *to++ = *from++;
  1004. X}
  1005. X#endif
  1006. X
  1007. Xlen_error(flag)
  1008. X{
  1009. X    char    *mesg = "[line too long]";
  1010. X
  1011. X    (flag == COMPLAIN) ? complain(mesg) : error(mesg);
  1012. X}
  1013. X
  1014. X/* Insert num number of c's at offset atchar in a linebuf of LBSIZE */
  1015. X
  1016. Xins_c(c, buf, atchar, num, max)
  1017. Xchar    c, *buf;
  1018. X{
  1019. X    register char    *pp, *pp1;
  1020. X    register int    len;
  1021. X    int    numchars;    /* Number of characters to copy forward */
  1022. X
  1023. X    if (num <= 0)
  1024. X        return;
  1025. X    len = atchar + strlen(&buf[atchar]);
  1026. X    if (len + num >= max)
  1027. X        len_error(COMPLAIN);
  1028. X    pp = &buf[len + 1];        /* + 1 so we can --pp (not pp--) */
  1029. X    pp1 = &buf[len + num + 1];
  1030. X    numchars = len - atchar;
  1031. X    while (numchars-- >= 0)
  1032. X        *--pp1 = *--pp;
  1033. X    pp = &buf[atchar];
  1034. X    while (--num >= 0)
  1035. X        *pp++ = c;
  1036. X}
  1037. X
  1038. XTwoBlank()
  1039. X{
  1040. X    register Line    *next = curline->l_next;
  1041. X
  1042. X    return ((next != 0) &&
  1043. X        (*(lcontents(next)) == '\0') &&
  1044. X        (next->l_next != 0) &&
  1045. X        (*(lcontents(next->l_next)) == '\0'));
  1046. X}
  1047. X
  1048. Xlinecopy(onto, atchar, from)
  1049. Xregister char    *onto,
  1050. X        *from;
  1051. X{
  1052. X    register char    *endp = &onto[LBSIZE - 2];
  1053. X
  1054. X    onto += atchar;
  1055. X
  1056. X    while (*onto = *from++)
  1057. X        if (onto++ >= endp)
  1058. X            len_error(ERROR);
  1059. X}
  1060. X
  1061. Xchar *
  1062. XIOerr(err, file)
  1063. Xchar    *err, *file;
  1064. X{
  1065. X    return sprint("Couldn't %s \"%s\".", err, file);
  1066. X}
  1067. X
  1068. Xpclose(p)
  1069. Xint    *p;
  1070. X{
  1071. X    (void) close(p[0]);
  1072. X    (void) close(p[1]);
  1073. X}
  1074. X
  1075. Xdopipe(p)
  1076. Xint    p[];
  1077. X{
  1078. X    if (pipe(p) == -1)
  1079. X        complain("[Pipe failed]");
  1080. X}
  1081. X
  1082. X/* NOSTRICT */
  1083. X
  1084. Xchar *
  1085. Xemalloc(size)
  1086. X{
  1087. X    char    *ptr;
  1088. X
  1089. X    if (ptr = malloc((unsigned) size))
  1090. X        return ptr;
  1091. X    /* Try garbage collecting lines */
  1092. X    GCchunks();
  1093. X    if (ptr = malloc((unsigned) size))
  1094. X        return ptr;
  1095. X    /* Uh ... Oh screw it! */
  1096. X    error("[Out of memory] ");
  1097. X    /* NOTREACHED */
  1098. X}
  1099. X
  1100. X/* Return the basename of file F. */
  1101. X
  1102. Xchar *
  1103. Xbasename(f)
  1104. Xregister char    *f;
  1105. X{
  1106. X    register char    *cp;
  1107. X
  1108. X    if (cp = rindex(f, '/'))
  1109. X        return cp + 1;
  1110. X    else
  1111. X        return f;
  1112. X}
  1113. X
  1114. Xpush_env(savejmp)
  1115. Xjmp_buf    savejmp;
  1116. X{
  1117. X    byte_copy((char *) mainjmp, (char *) savejmp, sizeof (jmp_buf));
  1118. X}
  1119. X
  1120. Xpop_env(savejmp)
  1121. Xjmp_buf    savejmp;
  1122. X{
  1123. X    byte_copy((char *) savejmp, (char *) mainjmp, sizeof (jmp_buf));
  1124. X}
  1125. X
  1126. X#ifdef LOAD_AV
  1127. X#  ifdef BSD4_2
  1128. X#    ifdef PURDUE_EE
  1129. X
  1130. Xget_la(dp)
  1131. Xdouble *dp;
  1132. X{
  1133. X    *dp = (double) loadav(0) / 100.0;
  1134. X}
  1135. X
  1136. X#    else PURDUE_EE
  1137. X
  1138. X#include <nlist.h>
  1139. X
  1140. Xstatic struct    nlist nl[] = {
  1141. X    { "_avenrun" },
  1142. X#define    X_AVENRUN    0
  1143. X    { "" }
  1144. X};
  1145. X
  1146. Xget_la(dp)
  1147. Xdouble    *dp;
  1148. X{
  1149. X    double    avenrun[3];
  1150. X    static int    kmem = 0;
  1151. X
  1152. X    if (kmem == -1) {
  1153. X        *dp = 4.0;    /* So shell commands will say "Chugging" */
  1154. X        return;
  1155. X    } else if (kmem == 0) {
  1156. X        if ((kmem = open("/dev/kmem", 0)) == -1) {
  1157. X            f_mess("Can't open kmem for load average.");
  1158. X            *dp = 4.0;
  1159. X            return;
  1160. X        }
  1161. X        nlist("/vmunix", nl);
  1162. X    }
  1163. X    lseek(kmem, (long) nl[X_AVENRUN].n_value, 0);
  1164. X    read(kmem, (char *) avenrun, sizeof(avenrun));
  1165. X    *dp = avenrun[0];
  1166. X}
  1167. X
  1168. X#    endif PURDUE_EE
  1169. X#  else BSD4_2
  1170. X
  1171. Xget_la(dp)
  1172. Xdouble    *dp;
  1173. X{
  1174. X    short    avg[3];
  1175. X
  1176. X    gldav(avg);
  1177. X    *dp = (double) avg[0] / 256;
  1178. X}
  1179. X
  1180. X#  endif BSD4_2
  1181. X#endif LOAD_AV
  1182. X
  1183. X/* get the time buf, designated by *timep, from FROM to TO. */
  1184. Xchar *
  1185. Xget_time(timep, buf, from, to)
  1186. Xchar    *buf;
  1187. Xtime_t    *timep;
  1188. X{
  1189. X    time_t    now;
  1190. X    char    *cp;
  1191. X    extern char    *ctime();
  1192. X
  1193. X    if (timep != 0)
  1194. X        now = *timep;
  1195. X    else
  1196. X        (void) time(&now);
  1197. X    cp = ctime(&now) + from;
  1198. X    if (to == -1)
  1199. X        cp[strlen(cp) - 1] = '\0';        /* Get rid of \n */
  1200. X    else
  1201. X        cp[to - from] = '\0';
  1202. X    if (buf) {
  1203. X        strcpy(buf, cp);
  1204. X        return buf;
  1205. X    } else
  1206. X        return cp;
  1207. X}
  1208. X
  1209. X/* Return length of null terminated string. */
  1210. X
  1211. Xstrlen(s)
  1212. Xregister char    *s;
  1213. X{
  1214. X    register char    *base = s + 1;    /* Can you say kludge? */
  1215. X
  1216. X    while (*s++)
  1217. X        ;
  1218. X    return (s - base);
  1219. X}
  1220. X
  1221. Xchar *
  1222. Xindex(s, c)
  1223. Xregister char    *s;
  1224. Xregister int    c;
  1225. X{
  1226. X    register int    c1;
  1227. X
  1228. X    if (c != 0)
  1229. X        while (c1 = *s++)
  1230. X            if (c == c1)
  1231. X                return s - 1;
  1232. X    return 0;
  1233. X}
  1234. X
  1235. Xstrcmp(s1, s2)
  1236. Xregister char    *s1,
  1237. X        *s2;
  1238. X{
  1239. X    if (!s1 || !s2)
  1240. X        return 1;    /* Which is not zero ... */
  1241. X    while (*s1 == *s2++)
  1242. X        if (*s1++ == '\0')
  1243. X            return 0;
  1244. X    return (*s1 - *--s2);
  1245. X}
  1246. X
  1247. Xcasecmp(s1, s2)
  1248. Xregister char    *s1,
  1249. X        *s2;
  1250. X{
  1251. X    if (!s1 || !s2)
  1252. X        return 1;    /* Which is not zero ... */
  1253. X    while (*s1 == *s2++ || Upper(*s1) == Upper(s2[-1]))
  1254. X        if (*s1++ == '\0')
  1255. X            return 0;
  1256. X    return (*s1 - *--s2);
  1257. X}
  1258. X
  1259. Xcasencmp(s1, s2, n)
  1260. Xregister char    *s1,
  1261. X        *s2;
  1262. Xregister int    n;
  1263. X{
  1264. X    if (!s1 || !s2)
  1265. X        return 1;    /* Which is not zero ... */
  1266. X    while (--n >= 0  && (*s1 == *s2++ || Upper(*s1) == Upper(s2[-1])))
  1267. X        if (*s1++ == '\0')
  1268. X            return 0;
  1269. X    return ((n < 0) ? 0 : *s1 - *--s2);
  1270. X}
  1271. X
  1272. Xnull_ncpy(to, from, n)
  1273. Xchar    *to,
  1274. X    *from;
  1275. X{
  1276. X    (void) strncpy(to, from, n);
  1277. X    to[n] = '\0';
  1278. X}
  1279. X
  1280. Xstrcpy(t, f)
  1281. Xregister char    *t,
  1282. X        *f;
  1283. X{
  1284. X    while (*t++ = *f++)
  1285. X        ;
  1286. X}
  1287. X
  1288. X/* Tries to pause for delay/10 seconds OR until a character is typed
  1289. X   at the keyboard.  This works well on BSD4_2 and not so well on the
  1290. X   rest.  Returns 1 if it returned because of keyboard input, or 0
  1291. X   otherwise. */
  1292. X
  1293. XSitFor(delay)
  1294. Xint    delay;
  1295. X{
  1296. X#ifdef BSD4_2
  1297. X#include <sys/time.h>
  1298. X
  1299. X    struct timeval    timer;
  1300. X    int    readfds = 1,
  1301. X        writefds = 0,
  1302. X        exceptfds = 0;
  1303. X
  1304. X    timer.tv_sec = (delay / 10);
  1305. X    timer.tv_usec = (delay % 10) * 100000;
  1306. X
  1307. X    if (charp())
  1308. X        return;
  1309. X    /* gross that I had to snarf this from getch() */
  1310. X    if (!UpdMesg && !Asking) {    /* Don't erase if we are asking */
  1311. X        if (mesgbuf[0] && !errormsg)
  1312. X            message(NullStr);
  1313. X    }
  1314. X    redisplay();
  1315. X    select(1, &readfds, &writefds, &exceptfds, &timer);
  1316. X#else
  1317. X    static int cps[] = {
  1318. X        0,
  1319. X        5,
  1320. X        7,
  1321. X        11,
  1322. X        13,
  1323. X        15,
  1324. X        20,
  1325. X        30,
  1326. X        60,
  1327. X        120,
  1328. X        180,
  1329. X        240,
  1330. X        480,
  1331. X        960,
  1332. X        1920,
  1333. X        1920,
  1334. X    };
  1335. X    register int    nchars;
  1336. X
  1337. X    if (charp())
  1338. X        return;
  1339. X    nchars = (delay * cps[ospeed]) / 10;
  1340. X    redisplay();
  1341. X    while ((--nchars > 0) && !InputPending) {
  1342. X        putchar(0);
  1343. X        if (OkayAbort) {
  1344. X            OkayAbort = 0;
  1345. X            InputPending = charp();
  1346. X        }
  1347. X    }
  1348. X#endif
  1349. X}
  1350. X
  1351. Xsindex(pattern, string)
  1352. Xregister char    *pattern,
  1353. X        *string;
  1354. X{
  1355. X    register int    len = strlen(pattern);
  1356. X
  1357. X    while (*string != '\0') {
  1358. X        if (*pattern == *string && strncmp(pattern, string, len) == 0)
  1359. X            return TRUE;
  1360. X        string++;
  1361. X    }
  1362. X    return FALSE;
  1363. X}
  1364. X
  1365. Xmake_argv(argv, ap)
  1366. Xregister char    *argv[];
  1367. Xva_list    ap;
  1368. X{
  1369. X    register char    *cp;
  1370. X    register int    i = 0;
  1371. X
  1372. X    argv[i++] = va_arg(ap, char *);
  1373. X    argv[i++] = basename(argv[0]);
  1374. X    while (cp = va_arg(ap, char *))
  1375. X        argv[i++] = cp;
  1376. X    argv[i] = 0;
  1377. X}
  1378. @//E*O*F util.c//
  1379. if test 13431 -ne "`wc -c <'util.c'`"; then
  1380.     echo shar: error transmitting "'util.c'" '(should have been 13431 characters)'
  1381. fi
  1382. fi # end of overwriting check
  1383. echo shar: extracting "'vars.c'" '(3332 characters)'
  1384. if test -f 'vars.c' ; then 
  1385.   echo shar: will not over-write existing file "'vars.c'"
  1386. else
  1387. sed 's/^X//' >vars.c <<'@//E*O*F vars.c//'
  1388. X/************************************************************************
  1389. X * This program is Copyright (C) 1986 by Jonathan Payne.  JOVE is       *
  1390. X * provided to you without charge, and with no warranty.  You may give  *
  1391. X * away copies of JOVE, including sources, provided that this notice is *
  1392. X * included in all the files.                                           *
  1393. X ************************************************************************/
  1394. X
  1395. X#include "jove.h"
  1396. X
  1397. Xstruct variable    variables[] = {
  1398. X    VARIABLE, "allow-^S-and-^Q", &OKXonXoff, V_BOOL|V_TTY_RESET,
  1399. X    VARIABLE, "allow-bad-filenames", &OkayBadChars, V_BOOL,
  1400. X#ifdef ABBREV
  1401. X    VARIABLE, "auto-case-abbrev", &AutoCaseAbbrev, V_BOOL,
  1402. X#endif
  1403. X#ifdef F_COMPLETION
  1404. X    VARIABLE, "bad-filename-extensions", (int *) BadExtensions, V_STRING,
  1405. X#endif
  1406. X    VARIABLE, "c-indentation-increment", &CIndIncrmt, V_BASE10,
  1407. X    VARIABLE, "case-ignore-search", &CaseIgnore, V_BOOL,
  1408. X#ifdef CMT_FMT
  1409. X     VARIABLE, "comment-format", (int *) CmtFmt, V_STRING,
  1410. X#endif
  1411. X#ifdef BIFF
  1412. X    VARIABLE, "disable-biff", &BiffChk, V_BOOL,
  1413. X#endif
  1414. X    VARIABLE, "error-window-size", &EWSize, V_BASE10,
  1415. X    VARIABLE, "file-creation-mode", &CreatMode, V_BASE8,
  1416. X    VARIABLE, "files-should-end-with-newline", &EndWNewline, V_BOOL,
  1417. X    VARIABLE, "internal-tabstop", &tabstop, V_BASE10|V_CLRSCREEN,
  1418. X    VARIABLE, "left-margin", &LMargin, V_BASE10,
  1419. X    VARIABLE, "mailbox", (int *) Mailbox, V_FILENAME,
  1420. X    VARIABLE, "mail-check-frequency", (int *) &MailInt, V_BASE10,
  1421. X#ifdef BACKUPFILES
  1422. X    VARIABLE, "make-backup-files", &BkupOnWrite, V_BOOL,
  1423. X#endif
  1424. X    VARIABLE, "mark-threshold", &MarkThresh, V_BASE10,
  1425. X    VARIABLE, "marks-should-float", &MarksShouldFloat, V_BOOL,
  1426. X    VARIABLE, "match-regular-expressions", &UseRE, V_BOOL,
  1427. X    VARIABLE, "meta-key", &MetaKey, V_BOOL|V_TTY_RESET,
  1428. X    VARIABLE, "mode-line", (int *) ModeFmt, V_STRING|V_MODELINE,
  1429. X    VARIABLE, "mode-line-should-standout", &BriteMode, V_BOOL|V_MODELINE,
  1430. X    VARIABLE, "paren-flash-delay", &PDelay, V_BASE10,
  1431. X    VARIABLE, "physical-tabstop", &phystab, V_BASE10|V_CLRSCREEN,
  1432. X#ifdef IPROCS
  1433. X    VARIABLE, "process-prompt", (int *) proc_prompt, V_STRING,
  1434. X#endif
  1435. X    VARIABLE, "interrupt-character", &IntChar, V_CHAR|V_TTY_RESET,
  1436. X    VARIABLE, "right-margin", &RMargin, V_BASE10,
  1437. X    VARIABLE, "scroll-step", &ScrollStep, V_BASE10,
  1438. X    VARIABLE, "search-exit-char", &SExitChar, V_CHAR,
  1439. X    VARIABLE, "send-typeout-to-buffer", &UseBuffers, V_BOOL,
  1440. X    VARIABLE, "shell", (int *) Shell, V_STRING,
  1441. X    VARIABLE, "shell-flags", (int *) ShFlags, V_STRING,
  1442. X    VARIABLE, "sync-frequency", &SyncFreq, V_BASE10,
  1443. X    VARIABLE, "tag-file", (int *) TagFile, V_FILENAME,
  1444. X    VARIABLE, "tmp-file-pathname", (int *) TmpFilePath, V_FILENAME,
  1445. X    VARIABLE, "update-time-frequency", &UpdFreq, V_BASE10,
  1446. X#ifdef ID_CHAR
  1447. X    VARIABLE, "use-i/d-char", &UseIC, V_BOOL,
  1448. X#endif
  1449. X    VARIABLE, "visible-bell", &VisBell, V_BOOL,
  1450. X    VARIABLE, "wrap-search", &WrapScan, V_BOOL,
  1451. X    VARIABLE, "write-files-on-make", &WtOnMk, V_BOOL,
  1452. X    VARIABLE, 0, 0, 0
  1453. X};
  1454. X
  1455. Xdata_obj *
  1456. Xfindvar(prompt)
  1457. Xchar    *prompt;
  1458. X{
  1459. X    static char    *strings[(sizeof variables) / sizeof (struct variable)];
  1460. X    static int    beenhere = 0;
  1461. X    register int    com;
  1462. X
  1463. X    if (beenhere == 0) {
  1464. X        register char    **strs = strings;
  1465. X        register struct variable    *v = variables;
  1466. X
  1467. X        beenhere = 1;
  1468. X        for (; v->Name; v++)
  1469. X            *strs++ = v->Name;
  1470. X        *strs = 0;
  1471. X    }
  1472. X
  1473. X    if ((com = complete(strings, prompt, NOTHING)) < 0)
  1474. X        return 0;
  1475. X    return (data_obj *) &variables[com];
  1476. X}
  1477. @//E*O*F vars.c//
  1478. if test 3332 -ne "`wc -c <'vars.c'`"; then
  1479.     echo shar: error transmitting "'vars.c'" '(should have been 3332 characters)'
  1480. fi
  1481. fi # end of overwriting check
  1482. echo shar: extracting "'wind.c'" '(8645 characters)'
  1483. if test -f 'wind.c' ; then 
  1484.   echo shar: will not over-write existing file "'wind.c'"
  1485. else
  1486. sed 's/^X//' >wind.c <<'@//E*O*F wind.c//'
  1487. X/************************************************************************
  1488. X * This program is Copyright (C) 1986 by Jonathan Payne.  JOVE is       *
  1489. X * provided to you without charge, and with no warranty.  You may give  *
  1490. X * away copies of JOVE, including sources, provided that this notice is *
  1491. X * included in all the files.                                           *
  1492. X ************************************************************************/
  1493. X
  1494. X/* This creates/deletes/divides/grows/shrinks windows.  */
  1495. X
  1496. X#include "jove.h"
  1497. X#include "termcap.h"
  1498. X
  1499. Xstatic char    onlyone[] = "You only have one window!",
  1500. X        toosmall[] = "Resulting window would be too small.";
  1501. X
  1502. XWindow    *curwind,
  1503. X    *fwind = 0;
  1504. X
  1505. X/* First line in a Window */
  1506. X
  1507. XFLine(w)
  1508. Xregister Window    *w;
  1509. X{
  1510. X    register Window    *wp = fwind;
  1511. X    register int    lineno = -1;
  1512. X
  1513. X    do {
  1514. X        if (wp == w)
  1515. X            return lineno + 1;
  1516. X        lineno += wp->w_height;
  1517. X        wp = wp->w_next;
  1518. X    } while (wp != fwind);
  1519. X    complain("window?");
  1520. X    /* NOTREACHED */
  1521. X}
  1522. X
  1523. X/* Delete `wp' from the screen.  If it is the only window left
  1524. X   on the screen, then complain.  It gives its body
  1525. X   to the next window if there is one, otherwise the previous
  1526. X   window gets the body.  */
  1527. X
  1528. Xdel_wind(wp)
  1529. Xregister Window    *wp;
  1530. X{
  1531. X    register Window    *prev = wp->w_prev;
  1532. X
  1533. X    if (one_windp())
  1534. X        complain(onlyone);
  1535. X
  1536. X    wp->w_prev->w_next = wp->w_next;
  1537. X    wp->w_next->w_prev = wp->w_prev;
  1538. X    
  1539. X    if (fwind == wp) {
  1540. X        fwind = wp->w_next;
  1541. X        fwind->w_height += wp->w_height;
  1542. X        /* Here try to do something intelligent for redisplay() */
  1543. X        SetTop(fwind, prev_line(fwind->w_top, wp->w_height));
  1544. X        if (curwind == wp)
  1545. X            SetWind(fwind);
  1546. X    } else {
  1547. X        prev->w_height += wp->w_height;
  1548. X        if (curwind == wp)
  1549. X            SetWind(prev);
  1550. X    }
  1551. X    free((char *) wp);
  1552. X}
  1553. X
  1554. X/* Divide the window WP N times, or at least once.  Complains if WP is too
  1555. X   small to be split into that many pieces.  It returns the new window. */
  1556. X
  1557. XWindow *
  1558. Xdiv_wind(wp, n)
  1559. Xregister Window    *wp;
  1560. X{
  1561. X    register Window    *new;
  1562. X    int    amt;
  1563. X
  1564. X    if (n < 1)
  1565. X        n = 1;
  1566. X    amt = wp->w_height / (n + 1);
  1567. X    if (amt < 2)
  1568. X        complain(toosmall);
  1569. X
  1570. X    while (--n >= 0) {
  1571. X        new = (Window *) emalloc(sizeof (Window));
  1572. X        new->w_flags = 0;
  1573. X
  1574. X        new->w_height = amt;
  1575. X        wp->w_height -= amt;
  1576. X
  1577. X        /* set the lines such that w_line is the center in
  1578. X           each Window */
  1579. X        new->w_line = wp->w_line;
  1580. X        new->w_char = wp->w_char;
  1581. X        new->w_bufp = wp->w_bufp;
  1582. X        new->w_top = prev_line(new->w_line, HALF(new));
  1583. X
  1584. X        /* Link the new window into the list */
  1585. X        new->w_prev = wp;
  1586. X        new->w_next = wp->w_next;
  1587. X        new->w_next->w_prev = new;
  1588. X        wp->w_next = new;
  1589. X    }
  1590. X    return new;
  1591. X}
  1592. X
  1593. X/* Initialze the first window setting the bounds to the size of the
  1594. X   screen.  There is no buffer with this window.  See parse for the
  1595. X   setting of this window. */
  1596. X
  1597. Xwinit()
  1598. X{
  1599. X    register Window    *w;
  1600. X
  1601. X    w = curwind = fwind = (Window *) emalloc(sizeof (Window));
  1602. X    w->w_line = w->w_top = 0;
  1603. X    w->w_flags = 0;
  1604. X    w->w_char = 0;
  1605. X    w->w_next = w->w_prev = fwind;
  1606. X    w->w_height = ILI;
  1607. X}
  1608. X
  1609. X/* Change to previous window. */
  1610. X
  1611. XPrevWindow()
  1612. X{
  1613. X    register Window    *new = curwind->w_prev;
  1614. X
  1615. X    if (one_windp())
  1616. X        complain(onlyone);
  1617. X    SetWind(new);
  1618. X}
  1619. X
  1620. X/* Make NEW the current Window */
  1621. X
  1622. XSetWind(new)
  1623. Xregister Window    *new;
  1624. X{
  1625. X    if (!Asking){        /* can you say kludge? */
  1626. X        curwind->w_line = curline;
  1627. X        curwind->w_char = curchar;
  1628. X        curwind->w_bufp = curbuf;
  1629. X    }
  1630. X    if (new == curwind)
  1631. X        return;
  1632. X    SetBuf(new->w_bufp);
  1633. X    if (!inlist(new->w_bufp->b_first, new->w_line)) {
  1634. X        new->w_line = curline;
  1635. X        new->w_char = curchar;
  1636. X    }
  1637. X    DotTo(new->w_line, new->w_char);
  1638. X    if (curchar > strlen(linebuf))
  1639. X        new->w_char = curchar = strlen(linebuf);
  1640. X    curwind = new;
  1641. X}
  1642. X
  1643. X/* delete the current window if it isn't the only one left */
  1644. X
  1645. XDelCurWindow()
  1646. X{
  1647. X    SetABuf(curwind->w_bufp);
  1648. X    del_wind(curwind);
  1649. X}
  1650. X
  1651. X/* put the current line of `w' in the middle of the window */
  1652. X
  1653. XCentWind(w)
  1654. Xregister Window    *w;
  1655. X{
  1656. X    SetTop(w, prev_line(w->w_line, HALF(w)));
  1657. X}
  1658. X
  1659. Xint    ScrollStep = 0;        /* full scrolling */
  1660. X
  1661. X/* Calculate the new topline of the window.  If ScrollStep == 0
  1662. X   it means we should center the current line in the window. */
  1663. X
  1664. XCalcWind(w)
  1665. Xregister Window    *w;
  1666. X{
  1667. X    register int    up;
  1668. X    Line    *newtop;
  1669. X
  1670. X    if (ScrollStep == 0)    /* Means just center it */
  1671. X        CentWind(w);
  1672. X    else {
  1673. X        up = inorder(w->w_line, 0, w->w_top, 0);
  1674. X        if (up == -1) {
  1675. X            CentWind(w);
  1676. X            return;
  1677. X        }
  1678. X        if (up)        /* Dot is above the screen */
  1679. X            newtop = prev_line(w->w_line, min(ScrollStep - 1, HALF(w)));
  1680. X        else
  1681. X            newtop = prev_line(w->w_line, (SIZE(w) - 1) -
  1682. X                        min(ScrollStep - 1, HALF(w)));
  1683. X        if (LineDist(newtop, w->w_top) >= SIZE(w) - 1)
  1684. X            CentWind(w);
  1685. X        else
  1686. X            SetTop(w, newtop);
  1687. X    }
  1688. X}
  1689. X
  1690. X/* This is bound to C-X 4 [BTF].  To make the screen stay the
  1691. X   same we have to remember various things, like the current
  1692. X   top line in the current window.  It's sorta gross, but it's
  1693. X   necessary because of the way this is implemented (i.e., in
  1694. X   terms of do_find(), do_select() which manipulate the windows. */
  1695. XWindFind()
  1696. X{
  1697. X    register Buffer    *obuf = curbuf,
  1698. X            *nbuf;
  1699. X    Line    *ltop = curwind->w_top;
  1700. X    Bufpos    savedot;
  1701. X    extern int
  1702. X        FindTag(),
  1703. X        BufSelect(),
  1704. X        FindFile();
  1705. X
  1706. X    DOTsave(&savedot);
  1707. X
  1708. X    switch (waitchar()) {
  1709. X    case 't':
  1710. X    case 'T':
  1711. X        ExecCmd((data_obj *) FindCmd(FindTag));
  1712. X        break;
  1713. X
  1714. X    case 'b':
  1715. X    case 'B':
  1716. X        ExecCmd((data_obj *) FindCmd(BufSelect));
  1717. X        break;
  1718. X
  1719. X    case 'f':
  1720. X    case 'F':
  1721. X        ExecCmd((data_obj *) FindCmd(FindFile));
  1722. X        break;
  1723. X
  1724. X    default:
  1725. X        complain("T: find-tag, F: find-file, B: select-buffer.");
  1726. X    }
  1727. X
  1728. X    nbuf = curbuf;
  1729. X    SetBuf(obuf);
  1730. X    SetDot(&savedot);
  1731. X    SetTop(curwind, ltop);    /* there! it's as if we did nothing */
  1732. X
  1733. X    if (one_windp())
  1734. X        (void) div_wind(curwind, 1);
  1735. X
  1736. X    tiewind(curwind->w_next, nbuf);
  1737. X    SetWind(curwind->w_next);
  1738. X}
  1739. X
  1740. X/* Go into one window mode by deleting all the other windows */
  1741. X
  1742. XOneWindow()
  1743. X{
  1744. X    while (curwind->w_next != curwind)
  1745. X        del_wind(curwind->w_next);
  1746. X}
  1747. X
  1748. XWindow *
  1749. Xwindbp(bp)
  1750. Xregister Buffer    *bp;
  1751. X{
  1752. X
  1753. X    register Window    *wp = fwind;
  1754. X
  1755. X    if (bp == 0)
  1756. X        return 0;
  1757. X    do {
  1758. X        if (wp->w_bufp == bp)
  1759. X            return wp;
  1760. X        wp = wp->w_next;
  1761. X    } while (wp != fwind);
  1762. X    return 0;
  1763. X}
  1764. X
  1765. X/* Change window into the next window.  Curwind becomes the new window. */
  1766. X
  1767. XNextWindow()
  1768. X{
  1769. X    register Window    *new = curwind->w_next;
  1770. X
  1771. X    if (one_windp())
  1772. X        complain(onlyone);
  1773. X    SetWind(new);
  1774. X}
  1775. X
  1776. X/* Scroll the next Window */
  1777. X
  1778. XPageNWind()
  1779. X{
  1780. X    if (one_windp())
  1781. X        complain(onlyone);
  1782. X    NextWindow();
  1783. X    NextPage();
  1784. X    PrevWindow();
  1785. X}
  1786. X
  1787. XWindow *
  1788. Xw_nam_typ(name, type)
  1789. Xregister char    *name;
  1790. X{
  1791. X    register Window *w;
  1792. X    register Buffer    *b;
  1793. X
  1794. X    b = buf_exists(name);
  1795. X    w = fwind;
  1796. X    if (b) do {
  1797. X        if (w->w_bufp == b)
  1798. X            return w;
  1799. X    } while ((w = w->w_next) != fwind);
  1800. X
  1801. X    w = fwind;
  1802. X    do {
  1803. X        if (w->w_bufp->b_type == type)
  1804. X            return w;
  1805. X    } while ((w = w->w_next) != fwind);
  1806. X
  1807. X    return 0;
  1808. X}
  1809. X
  1810. X/* Put a window with the buffer `name' in it.  Erase the buffer if
  1811. X   `clobber' is non-zero. */
  1812. X
  1813. Xpop_wind(name, clobber, btype)
  1814. Xregister char    *name;
  1815. X{
  1816. X    register Window    *wp;
  1817. X    register Buffer    *newb;
  1818. X
  1819. X    if (newb = buf_exists(name))
  1820. X        btype = -1;    /* if the buffer exists, don't change
  1821. X                   it's type */
  1822. X    if ((wp = w_nam_typ(name, btype)) == 0) {
  1823. X        if (one_windp())
  1824. X            SetWind(div_wind(curwind, 1));
  1825. X        else
  1826. X            PrevWindow();
  1827. X    } else
  1828. X        SetWind(wp);
  1829. X
  1830. X    newb = do_select((Window *) 0, name);
  1831. X    if (clobber) {
  1832. X        initlist(newb);
  1833. X        newb->b_modified = NO;
  1834. X    }
  1835. X    tiewind(curwind, newb);
  1836. X    if (btype != -1)
  1837. X        newb->b_type = btype;
  1838. X    SetBuf(newb);
  1839. X}
  1840. X
  1841. XGrowWindow()
  1842. X{
  1843. X    WindSize(curwind, abs(exp));
  1844. X}
  1845. X
  1846. XShrWindow()
  1847. X{
  1848. X    WindSize(curwind, -abs(exp));
  1849. X}
  1850. X
  1851. X/* Change the size of the window by inc.  First arg is the window,
  1852. X   second is the increment. */
  1853. X
  1854. XWindSize(w, inc)
  1855. Xregister Window    *w;
  1856. Xregister int    inc;
  1857. X{
  1858. X    if (one_windp())
  1859. X        complain(onlyone);
  1860. X
  1861. X    if (inc == 0)
  1862. X        return;
  1863. X    else if (inc < 0) {    /* Shrinking this Window. */
  1864. X        if (w->w_height + inc < 2)
  1865. X            complain(toosmall);
  1866. X        w->w_height += inc;
  1867. X        w->w_prev->w_height -= inc;
  1868. X    } else            /* Growing the window. */
  1869. X        WindSize(w->w_next, -inc);
  1870. X}
  1871. X
  1872. X/* Set the topline of the window, calculating its number in the buffer.
  1873. X   This is for numbering the lines only. */
  1874. X
  1875. XSetTop(w, line)
  1876. XWindow    *w;
  1877. Xregister Line    *line;
  1878. X{
  1879. X    register Line    *lp = w->w_bufp->b_first;
  1880. X    register int    num = 0;
  1881. X
  1882. X    w->w_top = line;
  1883. X    if (w->w_flags & W_NUMLINES) {
  1884. X        while (lp) {
  1885. X            num++;
  1886. X            if (line == lp)
  1887. X                break;
  1888. X            lp = lp->l_next;
  1889. X        }
  1890. X        w->w_topnum = num;
  1891. X    }
  1892. X}
  1893. X
  1894. XWNumLines()
  1895. X{
  1896. X    curwind->w_flags ^= W_NUMLINES; 
  1897. X    SetTop(curwind, curwind->w_top);
  1898. X}
  1899. X
  1900. XWVisSpace()
  1901. X{
  1902. X    curwind->w_flags ^= W_VISSPACE;
  1903. X    ClAndRedraw();
  1904. X}
  1905. X
  1906. X/* Return the line number that `line' occupies in `windes' */
  1907. X
  1908. Xin_window(windes, line)
  1909. Xregister Window    *windes;
  1910. Xregister Line    *line;
  1911. X{
  1912. X    register int    i;
  1913. X    register Line    *top = windes->w_top;
  1914. X
  1915. X    for (i = 0; top && i < windes->w_height - 1; i++, top = top->l_next)
  1916. X        if (top == line)
  1917. X            return FLine(windes) + i;
  1918. X    return -1;
  1919. X}
  1920. X
  1921. XSplitWind()
  1922. X{
  1923. X    SetWind(div_wind(curwind, exp_p ? (exp - 1) : 1));
  1924. X}
  1925. @//E*O*F wind.c//
  1926. if test 8645 -ne "`wc -c <'wind.c'`"; then
  1927.     echo shar: error transmitting "'wind.c'" '(should have been 8645 characters)'
  1928. fi
  1929. fi # end of overwriting check
  1930. echo shar: extracting "'doc/README'" '(306 characters)'
  1931. if test -f 'doc/README' ; then 
  1932.   echo shar: will not over-write existing file "'doc/README'"
  1933. else
  1934. sed 's/^X//' >doc/README <<'@//E*O*F doc/README//'
  1935. XTo create the jove manual (as opposed to the man pages)
  1936. Xjust do "nroff -ms jove.[12345]" (or ditroff or troff).
  1937. XThat should do the trick.  The man pages will be installed
  1938. Xautomatically by "make install" in the previous directory.
  1939. XAnd the online/run-time documentation will be installed
  1940. Xautomatically, too.
  1941. @//E*O*F doc/README//
  1942. if test 306 -ne "`wc -c <'doc/README'`"; then
  1943.     echo shar: error transmitting "'doc/README'" '(should have been 306 characters)'
  1944. fi
  1945. fi # end of overwriting check
  1946. echo shar: extracting "'doc/example.rc'" '(715 characters)'
  1947. if test -f 'doc/example.rc' ; then 
  1948.   echo shar: will not over-write existing file "'doc/example.rc'"
  1949. else
  1950. sed 's/^X//' >doc/example.rc <<'@//E*O*F doc/example.rc//'
  1951. Xif /ua/jonathan/src/jove/lib/isttytype iq120
  1952. X    bind-to-key Prefix-1 \\
  1953. X    bind-to-key set-mark ^[ 
  1954. X    set allow-^S-and-^Q on
  1955. Xendif
  1956. Xif /ua/jonathan/src/jove/lib/modemp
  1957. X    set mode-line  -%n %m "%f" %((%t%s%C%s%l)%)
  1958. Xelse
  1959. X    set mode-line  -%n- %["%f" %m [%b] %]%s%((%t%s%C%s%l)%)%s(%M) %e
  1960. Xendif
  1961. Xauto-execute-command show-match .*\.[ch]$
  1962. Xset comment-format /* %!   %c%! */
  1963. Xset disable-biff on
  1964. Xset match-regular-expressions on
  1965. Xset use-i/d-char off
  1966. Xbind-to-key backward-paragraph ^[[
  1967. Xbind-to-key current-error ^X^C
  1968. Xbind-to-key exit-jove ^X^Z
  1969. Xbind-to-key find-tag-at-point ^[^T
  1970. Xbind-to-key grow-window ^Xg
  1971. Xbind-to-key kill-s-expression ^[^K
  1972. Xbind-to-key list-processes ^X^L
  1973. Xbind-to-key scroll-down ^C
  1974. Xbind-to-key shrink-window ^Xs
  1975. @//E*O*F doc/example.rc//
  1976. if test 715 -ne "`wc -c <'doc/example.rc'`"; then
  1977.     echo shar: error transmitting "'doc/example.rc'" '(should have been 715 characters)'
  1978. fi
  1979. fi # end of overwriting check
  1980. echo shar: extracting "'doc/jove.3'" '(13444 characters)'
  1981. if test -f 'doc/jove.3' ; then 
  1982.   echo shar: will not over-write existing file "'doc/jove.3'"
  1983. else
  1984. sed 's/^X//' >doc/jove.3 <<'@//E*O*F doc/jove.3//'
  1985. X.NH 1
  1986. XDirectory Handling
  1987. X.XS \n(PN
  1988. X\*(SN Directory Handling
  1989. X.XE
  1990. X.LP
  1991. XTo save having to use absolute pathnames when you want to edit a nearby file
  1992. X\s-2JOVE\s0 allows you to move around the
  1993. X.UX
  1994. Xfilesystem just as the c-shell does.
  1995. XThese commands are:
  1996. X.IP "cd dir" 15n
  1997. XChange to the specified directory.
  1998. X.IP "pushd [dir]"
  1999. XLike \fIcd\fP, but save the old directory on the directory stack.
  2000. XWith no directory argument, simply exchange the top two directories
  2001. Xon the stack and \fIcd\fP to the new top.
  2002. X.IP "popd"
  2003. XTake the current directory off the stack and \fIcd\fP to the directory now
  2004. Xat the top.
  2005. X.IP "dirs"
  2006. XDisplay the contents of the directory stack.
  2007. X.LP
  2008. XThe names and behavior of these commands were chosen to mimic those in the c-shell.
  2009. X.NH 1
  2010. XEditing C Programs
  2011. X.XS \n(PN
  2012. X\*(SN Editing C Programs
  2013. X.XE
  2014. X.LP
  2015. XThis section details the support provided by \s-2JOVE\s0
  2016. Xfor working on C programs.
  2017. X.NH 2
  2018. XIndentation Commands
  2019. X.XS \n(PN 5n
  2020. X\*(SN Indentation Commands
  2021. X.XE
  2022. X.LP
  2023. XTo save having to lay out C programs "by hand", \s-2JOVE\s0
  2024. Xhas an idea of the correct indentation of a line,
  2025. Xbased on the surrounding context.
  2026. XWhen you are in C Mode, \s-2JOVE\s0 treats tabs specially \(em
  2027. Xtyping a tab at the beginning of a new line means "indent to
  2028. Xthe right place".
  2029. XClosing braces are also handled specially, and are indented
  2030. Xto match the corresponding open brace.
  2031. X.NH 2
  2032. XParenthesis and Brace Matching
  2033. X.XS \n(PN 5n
  2034. X\*(SN Parenthesis and Brace Matching
  2035. X.XE
  2036. X.LP
  2037. XTo check that parentheses and braces match the way you think they do,
  2038. Xturn on \fIShow Match\fP mode (ESC X show-match-mode).  Then, whenever
  2039. Xyou type a close brace or parenthesis, the cursor moves momentarily to
  2040. Xthe matching opener, if it's currently visible.  If it's not visible,
  2041. X\s-2JOVE\s0 displays the line containing the matching opener on the message
  2042. Xline.
  2043. X.NH 2
  2044. XC Tags
  2045. X.XS \n(PN 5n
  2046. X\*(SN C Tags
  2047. X.XE
  2048. X.LP
  2049. XOften when you are editing a C program,
  2050. Xespecially someone else's code,
  2051. Xyou see a function call and wonder what that function does.
  2052. XYou then search for the function within the current file and if you're
  2053. Xlucky find
  2054. Xthe definition, finally returning to the original spot when you are done.
  2055. XHowever, if are unlucky, the function turns out to be external
  2056. X(defined in another file) and
  2057. Xyou have to suspend the edit,
  2058. X\fIgrep\fP for the function name in every .c that might contain it,
  2059. Xand finally visit the appropriate file.
  2060. X.LP
  2061. XTo avoid this diversion or the need to remember which
  2062. Xfunction is defined in which file,
  2063. XBerkeley 
  2064. X.UX
  2065. Xhas a program called \fIctags(1)\fP, which
  2066. Xtakes a set of source files and looks for function
  2067. Xdefinitions, producing a file called \fItags\fP as its output.
  2068. X.LP
  2069. X\s-2JOVE\s0 has a command called C-X T (\fIfind-tag\fP)
  2070. Xthat prompts you for the name of a function (a \fItag\fP), looks up
  2071. Xthe tag reference in the previously constructed tags file, 
  2072. Xthen visits the file containing that tag in a new buffer,
  2073. Xwith point positioned at the definition of the function.
  2074. XThere is another version of this command, namely \fIfind-tag-at-point\fP,
  2075. Xthat uses the identifier at 
  2076. X.I point.
  2077. X.LP
  2078. XSo, when you've added new functions to a module, or moved some old
  2079. Xones around, run the \fIctags\fP program to regenerate the \fItags\fP file.
  2080. X\s-2JOVE\s0 looks in the file specified in the \fItag-file\fP variable.  The
  2081. Xdefault is "./tags", that is, the tag file in the current directory.  If you
  2082. Xwish to use an alternate tag file, you use C-U\ C-X\ T, and \s-2JOVE\s0 will
  2083. Xprompt for a file name.  If you find yourself specifying the same file again
  2084. Xand again, you can set \fItag-file\fP to that file, and run
  2085. X\fIfind-tag\fP with no numeric argument.
  2086. X.LP
  2087. XTo begin an editing session looking for a particular tag, use
  2088. Xthe \fI\-t tag\fP command line option to \s-2JOVE\s0.
  2089. XFor example, say you wanted to look at the file containing the tag
  2090. X\fISkipChar\fP, you would invoke \s-2JOVE\s0 as:
  2091. X.DS I
  2092. X.I
  2093. X% jove \-t SkipChar
  2094. X.R
  2095. X.DE
  2096. X.NH 2
  2097. XCompiling Your Program
  2098. X.XS \n(PN 5n
  2099. X\*(SN Compiling Your Program
  2100. X.XE
  2101. X.LP
  2102. XYou've typed in a program or altered an existing one and now you
  2103. Xwant to run it through the compiler to check for errors.
  2104. XTo save having to suspend the edit,
  2105. Xrun the compiler,
  2106. Xscribble down error messages, and then resume the edit,
  2107. X\s-2JOVE\s0 allows you to compile your code while in the editor.
  2108. XThis is done with the C-X C-E (\fIcompile-it\fP) command.
  2109. XIf you run \fIcompile-it\fP with no argument
  2110. Xit runs the
  2111. X.UX
  2112. X\fImake\fP
  2113. Xprogram into a buffer;
  2114. XIf you need a special command or want to pass arguments to \fImake\fP,
  2115. Xrun \fIcompile-it\fP with any argument (C-U is good enough) and you
  2116. Xwill be prompted for the command to execute.
  2117. X.LP
  2118. XIf any error messages are produced, they are treated specially by \s-2JOVE\s0.
  2119. XThat treatment is the subject of the next section.
  2120. X.NH 2
  2121. XError Message Parsing and Spelling Checking
  2122. X.XS \n(PN
  2123. X\*(SN Error Message Parsing
  2124. X\*(SN Spelling Checking
  2125. X.XE
  2126. X.LP
  2127. X\s-2JOVE\s0 knows how to interpret the error messages from many
  2128. X.UX
  2129. Xcommands;
  2130. XIn particular,
  2131. Xthe messages from \fIcc\fP,
  2132. X\fIgrep\fP and \fIlint\fP can be understood.
  2133. XAfter running the \fIcompile-it\fP command,
  2134. Xthe \fIparse-errors\fP command is automatically executed,
  2135. Xand any errors found are displayed in a new buffer.
  2136. XThe files whose names are found in parsing the error messages are each
  2137. Xbrought into \s-2JOVE\s0 buffers and the point is positioned at the first error
  2138. Xin the first file.
  2139. XThe commands \fIcurrent-error\fP, C-X C-N (\fInext-error\fP), and
  2140. XC-X C-P (\fIprevious-error\fP)
  2141. Xcan be used to traverse the list of errors.
  2142. X.LP
  2143. XIf you already have a file called
  2144. X\fIerrs\fP containing, say, c compiler messages then you can get \s-2JOVE\s0 to interpret the messages by
  2145. Xinvoking it as:
  2146. X.DS I
  2147. X.I
  2148. X% jove \-p errs
  2149. X.R
  2150. X.DE
  2151. X.LP
  2152. X\s-2JOVE\s0 has a special mechanism for checking the the spelling of a document;
  2153. XIt runs the
  2154. X.UX
  2155. Xspell program into a buffer.
  2156. XYou then delete from this buffer all those words that are not spelling
  2157. Xerrors and then \s-2JOVE\s0 runs the \fIparse-spelling-errors\fP command to
  2158. Xyield a list of errors just as in the last section.
  2159. X.NH 1
  2160. XSimple Customization
  2161. X.XS \n(PN
  2162. X\*(SN Simple Customization
  2163. X.XE
  2164. X.LP
  2165. X.NH 2
  2166. XMajor Modes
  2167. X.XS \n(PN 5n
  2168. X\*(SN Major Modes
  2169. X.XE
  2170. X.LP
  2171. XTo help with editing particular types of file, say a paper or a C program,
  2172. X\s-2JOVE\s0 has several \fImajor modes\fP.
  2173. XThese are as follows:
  2174. X.NH 3
  2175. XText mode
  2176. X.XS \n(PN 10n
  2177. X\*(SN Text mode
  2178. X.XE
  2179. X.LP
  2180. XThis is the default major mode.  Nothing special is done.
  2181. X.NH 3
  2182. XC mode
  2183. X.XS \n(PN 10n
  2184. X\*(SN C mode
  2185. X.XE
  2186. X.LP
  2187. XThis mode affects the behavior of the tab and parentheses characters.
  2188. XInstead of just inserting the tab, \s-2JOVE\s0 determines
  2189. Xwhere the text "ought" to line up for the C language and tabs to that position
  2190. Xinstead.  The same thing happens with the close brace and close parenthesis;
  2191. Xthey are tabbed to the "right" place and then inserted.
  2192. XUsing the \fIauto-execute-command\fP command, you can make \s-2JOVE\s0 enter
  2193. X\fIC Mode\fP whenever you edit a file whose name ends in \fI.c\fP.
  2194. X.NH 3
  2195. XLisp mode
  2196. X.XS \n(PN 10n
  2197. X\*(SN Lisp mode
  2198. X.XE
  2199. X.LP
  2200. XThis mode is analogous to \fIC Mode\fP,
  2201. Xbut performs the indentation needed to lay out Lisp programs properly.
  2202. XNote also the \fIgrind-s-expr\fP command that prettyprints an
  2203. X\fIs-expression\fP and the \fIkill-mode-expression\fP command.
  2204. X.NH 2
  2205. XMinor Modes
  2206. X.XS \n(PN 5n
  2207. X\*(SN Minor Modes
  2208. X.XE
  2209. X.LP
  2210. XIn addition to the major modes,
  2211. X\s-2JOVE\s0 has a set of minor modes.
  2212. XThese are as follows:
  2213. X.NH 3
  2214. XAuto Indent
  2215. X.XS \n(PN 10n
  2216. X\*(SN Auto Indent
  2217. X.XE
  2218. X.LP
  2219. XIn this mode,
  2220. X\s-2JOVE\s0 indents each line the same way as that above it.  That is,
  2221. Xthe Return key in this mode acts as the Linefeed key ordinarily does.
  2222. X.NH 3
  2223. XShow Match
  2224. X.XS \n(PN 10n
  2225. X\*(SN Show Match
  2226. X.XE
  2227. X.LP
  2228. XMove the cursor momentarily to the matching opening parenthesis when a closing
  2229. Xparenthesis is typed.
  2230. X.NH 3
  2231. XAuto Fill
  2232. X.XS \n(PN 10n
  2233. X\*(SN Auto Fill
  2234. X.XE
  2235. X.LP
  2236. XIn \fIAuto Fill\fP mode,
  2237. Xa newline is automatically inserted when the line length
  2238. Xexceeds the right margin.
  2239. XThis way,
  2240. Xyou can type a whole paper without having to use the Return key.
  2241. X.NH 3
  2242. XOver Write
  2243. X.XS \n(PN 10n
  2244. X\*(SN Over Write
  2245. X.XE
  2246. X.LP
  2247. XIn this mode,
  2248. Xany text typed in will replace the previous contents.
  2249. X(The default is for new text to be inserted and "push" the old along.)
  2250. XThis is useful for editing an already-formatted diagram in which you
  2251. Xwant to change some things without moving other things around on the
  2252. Xscreen.
  2253. X.NH 3
  2254. XWord Abbrev
  2255. X.XS \n(PN 10n
  2256. X\*(SN Word Abbrev
  2257. X.XE
  2258. X.LP
  2259. XIn this mode, every word you type is compared to a list of word
  2260. Xabbreviations; whenever you type an abbreviation, it is replaced
  2261. Xby the text that it abbreviates.
  2262. XThis can save typing if a particular word or phrase must be entered
  2263. Xmany times.
  2264. XThe abbreviations and their expansions are held in a file that looks like:
  2265. X.DS I
  2266. Xabbrev:phrase
  2267. X.DE
  2268. XThis file can be set up in your \fI~/.\|joverc\fP with the \fIread-word-abbrev-file\fP command.
  2269. XThen, whenever you are editing a buffer in \fIWord Abbrev\fP mode,
  2270. X\s-2JOVE\s0 checks for the abbreviations you've given.
  2271. XSee also the commands
  2272. X\fIread-word-abbrev-file\fP,
  2273. X\fIwrite-word-abbrev-file\fP,
  2274. X\fIedit-word-abbrevs\fP,
  2275. X\fIdefine-global-word-abbrev\fP,
  2276. X\fIdefine-mode-word-abbrev\fP,
  2277. Xand \fIbind-macro-to-word-abbrev\fP,
  2278. Xand the variable \fIauto-case-abbrev\fP.
  2279. X.NH 2
  2280. XVariables
  2281. X.XS \n(PN 5n
  2282. X\*(SN Variables
  2283. X.XE
  2284. X.LP
  2285. X\s-2JOVE\s0 can be tailored to suit your needs by changing the
  2286. Xvalues of variables.
  2287. XA \s-2JOVE\s0 variable can be given a value with the \fIset\fP command,
  2288. Xand its value displayed with the \fIprint\fP command.
  2289. X.LP
  2290. XThe variables \s-2JOVE\s0 understands are listed along with the commands
  2291. Xin the alphabetical list at the end of this document.
  2292. X.NH 2
  2293. XKey Re-binding
  2294. X.XS \n(PN 5n
  2295. X\*(SN Key Re-binding
  2296. X.XE
  2297. X.LP
  2298. XMany of the commands built into \s-2JOVE\s0 are not bound to
  2299. Xspecific keys.
  2300. XThe command handler in
  2301. X\s-2JOVE\s0 is used to invoke these commands and is activated
  2302. Xby the \fIexecute-extended-command\fP command (ESC X).
  2303. XWhen the name of a command typed in is unambiguous,
  2304. Xthat command will be executed.
  2305. XSince it is very slow to have
  2306. Xto type in the name of each command every time it is needed,
  2307. X\s-2JOVE\s0 makes it possible to \fIbind\fP commands to keys.
  2308. XWhen a command is
  2309. X\fIbound\fP to a key any future hits on that key will invoke that command.
  2310. XAll the printing characters are initially bound to the
  2311. Xcommand \fIself-insert\fP.
  2312. XThus, typing any printing character causes it to be inserted into the text.
  2313. XAny of the existing commands can be bound to any key.
  2314. X(A \fIkey\fP may actually be a \fIcontrol character\fP
  2315. Xor an \fIescape sequence\fP as explained previously under
  2316. X\fICommand Input Conventions\fP).
  2317. X.LP
  2318. XSince there are more commands than there are keys,
  2319. Xtwo keys are treated as \fIprefix\fP commands.
  2320. XWhen a key bound to one of the prefix commands is typed,
  2321. Xthe next character
  2322. Xtyped is interpreted on the basis that it was preceded by one of the
  2323. Xprefix keys.
  2324. XInitially ^X and ESC are the prefix keys and
  2325. Xmany of the built in commands are initially bound to these "two stroke" keys.
  2326. X(For historical reasons, the Escape key is often referred to as "Meta").
  2327. X.NH 2
  2328. XKeyboard Macros
  2329. X.XS \n(PN 5n
  2330. X\*(SN Keyboard Macros
  2331. X.XE
  2332. X.LP
  2333. XAlthough \s-2JOVE\s0 has many powerful commands,
  2334. Xyou often find that you have a task that no individual command can do.
  2335. X\s-2JOVE\s0 allows you to define your own commands from sequences
  2336. Xof existing ones "by example";
  2337. XSuch a sequence is termed a \fImacro\fP.
  2338. XThe procedure is as follows:
  2339. XFirst you type the \fIstart-remembering\fP command,
  2340. Xusually bound to C-X (.
  2341. XNext you "perform" the commands which as they are being executed are
  2342. Xalso 
  2343. Xremembered, which will constitute the body of the macro.
  2344. XThen you give the \fIstop-remembering\fP command, usually bound to
  2345. XC-X ).
  2346. XYou now have a \fIkeyboard macro\fP.
  2347. XTo run this command sequence again,
  2348. Xuse the command \fIexecute-keyboard-macro\fP, usually bound to
  2349. XC-X E.
  2350. XYou may find this bothersome to type and re-type,
  2351. Xso there is a way to bind the macro to a key.
  2352. XFirst,
  2353. Xyou must give the keyboard macro a name using the
  2354. X\fIname-keyboard-macro\fP command.
  2355. XThen the binding is made with the \fIbind-macro-to-key\fP command.
  2356. XWe're still not finished because all this hard work will be lost
  2357. Xif you leave \s-2JOVE\s0.
  2358. XWhat you do is to save your macros into a file
  2359. Xwith the \fIwrite-macros-to-file\fP command.
  2360. XThere is a corresponding \fIread-macros-from-file\fP command to retrieve
  2361. Xyour macros in the next editing session.
  2362. X.NH 2
  2363. XInitialization Files
  2364. X.XS \n(PN 5n
  2365. X\*(SN Initialization Files
  2366. X.XE
  2367. X.LP
  2368. XUsers will likely want to modify the default key bindings to their liking.
  2369. XSince it would be quite annoying to have to set up the bindings
  2370. Xeach time \s-2JOVE\s0 is started up,
  2371. X\s-2JOVE\s0 has the ability to read in a "startup" file.
  2372. XWhenever \s-2JOVE\s0 is started,
  2373. Xit reads commands from the file \fI.\|joverc\fP in the user's home directory.
  2374. XThese commands are read as
  2375. Xif they were typed to the command handler (ESC X) during an edit.
  2376. XThere can be only one command per line in the startup file.
  2377. XIf there is a file \fI/usr/lib/jove/joverc\fP,
  2378. Xthen this file will be read before the user's
  2379. X.I .\|joverc
  2380. Xfile.
  2381. XThis can be used to set up a system-wide default startup mode for
  2382. X\s-2JOVE\s0
  2383. Xthat is tailored to the needs of that system.
  2384. X.LP
  2385. XThe \fIsource\fP command can be used to read commands from a specified file
  2386. Xat any time during an editing session,
  2387. Xeven from inside the \fI.\|joverc\fP file.
  2388. XThis means that a macro can be used to change the key bindings,
  2389. Xe.g., to enter a mode,
  2390. Xby reading from a specified file which contains all the necessary bindings.
  2391. @//E*O*F doc/jove.3//
  2392. if test 13444 -ne "`wc -c <'doc/jove.3'`"; then
  2393.     echo shar: error transmitting "'doc/jove.3'" '(should have been 13444 characters)'
  2394. fi
  2395. fi # end of overwriting check
  2396. echo shar: extracting "'doc/system.rc'" '(377 characters)'
  2397. if test -f 'doc/system.rc' ; then 
  2398.   echo shar: will not over-write existing file "'doc/system.rc'"
  2399. else
  2400. sed 's/^X//' >doc/system.rc <<'@//E*O*F doc/system.rc//'
  2401. Xauto-execute-command auto-fill-mode /tmp/Re\|/tmp/article
  2402. Xauto-execute-command show-match .*\.[lchy]$\|.*\.lisp$\|.*\.scm$\|.*\.slisp
  2403. Xauto-execute-command c-mode .*\.[chy]$
  2404. Xauto-execute-command lisp-mode .*\.l$\|.*\.lisp$\|.*\.scm$\|.*\.slisp
  2405. Xbind-to-key pause-jove ^[S
  2406. Xbind-to-key pause-jove ^[s
  2407. Xprocess-bind-to-key interrupt-process ^C
  2408. Xprocess-bind-to-key process-newline ^M
  2409. @//E*O*F doc/system.rc//
  2410. if test 377 -ne "`wc -c <'doc/system.rc'`"; then
  2411.     echo shar: error transmitting "'doc/system.rc'" '(should have been 377 characters)'
  2412. fi
  2413. fi # end of overwriting check
  2414. echo shar: extracting "'doc/teachjove.nr'" '(726 characters)'
  2415. if test -f 'doc/teachjove.nr' ; then 
  2416.   echo shar: will not over-write existing file "'doc/teachjove.nr'"
  2417. else
  2418. sed 's/^X//' >doc/teachjove.nr <<'@//E*O*F doc/teachjove.nr//'
  2419. X.hy 0
  2420. X.TH TEACHJOVE 1 "12 February 1986"
  2421. X.ad
  2422. X.SH NAME
  2423. XTEACHJOVE - learn how to use the JOVE editor
  2424. X.SH SYNOPSIS
  2425. Xteachjove
  2426. X.SH DESCRIPTION
  2427. XTEACHJOVE is a simple program that calls up the JOVE editor on a special
  2428. Xfile that is an interactive tutorial for the JOVE editor.  Once in JOVE
  2429. Xall you do is follow the instructions and by doing so you will learn all
  2430. Xabout JOVE!  NOTE: TEACHJOVE actually makes a copy of the tutorial in
  2431. Xyour home directory; if you ever want to start over (if you trash the
  2432. Xfile by accident) all you need to do is remove the file "~/teach-jove"
  2433. Xand run teachjove again.
  2434. X.SH FILES
  2435. XLIBDIR/teach-jove -- THE special file.
  2436. X.SH SEE ALSO
  2437. XJOVE(1) - to learn about JOVE in general.
  2438. X.fi
  2439. X.SH AUTHOR
  2440. XJonathan Payne
  2441. @//E*O*F doc/teachjove.nr//
  2442. if test 726 -ne "`wc -c <'doc/teachjove.nr'`"; then
  2443.     echo shar: error transmitting "'doc/teachjove.nr'" '(should have been 726 characters)'
  2444. fi
  2445. fi # end of overwriting check
  2446. echo shar: "End of archive 8 (of 13)."
  2447. cp /dev/null ark8isdone
  2448. DONE=true
  2449. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13; do
  2450.     if test -f ark${I}isdone; then
  2451.         echo "You have run archive ${I}."
  2452.     else
  2453.         echo "You still need to run archive ${I}."
  2454.         DONE=false
  2455.     fi
  2456. done
  2457. case $DONE in
  2458.     true)
  2459.         echo "You have run all 13 archives."
  2460.         echo 'Now read the README and Makefile.'
  2461.         ;;
  2462. esac
  2463. ##  End of shell archive.
  2464. exit 0
  2465.